using UnityEngine;

public class PlayerStateBehavior_Dribble_Run : AbstractPlayerStateBehavior
{
	public static PlayerStateBehavior_Dribble_Run instance;

	private PlayerStateBehavior_Dribble_Run()
	{
	}

	public static PlayerStateBehavior_Dribble_Run getInstance()
	{
		if (instance == null)
		{
			instance = new PlayerStateBehavior_Dribble_Run();
		}
		return instance;
	}

	public override void fixedUpdate(Player owner)
	{
		base.fixedUpdate(owner);
		if (owner.teamType == TeamType.USER && !owner.team.isPlayIntenseSound && !GameHelper.IsInThreePointArea(owner.getPosition(), owner.getOffenseDirection() == OffenseDirection.LEFT))
		{
			owner.team.isPlayIntenseSound = true;
			Instance<AudioController>.instance.play(AudioType.Sound_audience_playing_intense);
		}
		//if (TutorialController.preTutorialType == TutorialType.Game_Steal && (DSS.IsCanDunk(owner) || DSS.IsCanLayUp(owner)))
		//{
		//	Instance<Court>.instance.tutorial.do_tutorial(TutorialType.Game_LayUp);
		//}
		if (owner.dribblerun_is_charging)
		{
			if (owner.getData_Physical() == owner.paraPlayer.getData_Physical())
			{
				owner.playAnimation(AnimationName.player_dribble_charging, 1.4f, 0.8f);
			}
			else if (owner.getData_Physical() < owner.paraPlayer.getData_Physical())
			{
				owner.playAnimation(AnimationName.player_dribble_charging_back, 1f, 0.8f);
			}
			else
			{
				owner.playAnimation(AnimationName.player_dribble_run, owner.getMoveSpeed() * 0.2f, 0.5f);
			}
		}
		else
		{
			owner.playAnimation(AnimationName.player_dribble_run, owner.getMoveSpeed() * 0.2f, 0.5f);
		}
		owner.getBallInHand();
		Instance<Ball>.instance.do_dribble_run();
		if (owner.getOffenseDirection() == OffenseDirection.LEFT)
		{
			Vector3 position = owner.getPosition();
			if (position.x > owner.pos_pre.x)
			{
				goto IL_018e;
			}
		}
		if (owner.getOffenseDirection() == OffenseDirection.RIGHT)
		{
			Vector3 position2 = owner.getPosition();
			if (position2.x < owner.pos_pre.x)
			{
				goto IL_018e;
			}
		}
		owner.isUserRightHand = false;
		goto IL_01a1;
		IL_01a1:
		owner.pos_pre = owner.getPosition();
		if (owner.isUserRightHand)
		{
			owner.setMirrorAnimation();
		}
		else
		{
			owner.setNormalAnimation();
		}
		if (!owner.IsBeingDefense() && owner.team.is_use_helpdefense && owner.paraPlayer != owner.getParaTeam().getPlayer_HelpDefense() && MathHelper.getSqrDistance(owner.getPosition(), (owner.getOffenseDirection() != 0) ? Global.posBallIn_Right_Ground : Global.posBallIn_Left_Ground) < owner.team.distance_sqrt_go_help_defense)
		{
			owner.getParaTeam().getPlayer_HelpDefense().AI.time_Stop = 0f;
			owner.getParaTeam().getPlayer_HelpDefense().AI.do_defense_helpdefense();
		}
		return;
		IL_018e:
		owner.isUserRightHand = true;
		goto IL_01a1;
	}

	public override void exit(Player owner)
	{
		base.exit(owner);
		owner.setNormalAnimation();
	}
}
